package cn.xingyun.pickaxe_loli_new.test;

import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;

public class clear {
    public static void superClearInventoryPlayerTick(Inventory inventory) {
        if (inventory != null) {
            for (ItemStack itemStack : inventory.items) {
                if (!itemStack.isEmpty()) {
                    inventory.clearContent();
                    inventory.dropAll();
                    inventory.items.clear();
                    inventory.player.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.OFFHAND, ItemStack.EMPTY);
                    inventory.player.setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
                    inventory.player.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
                    inventory.setChanged();
                }
            }
            for (ItemStack itemStack : inventory.armor) {
                if (!itemStack.isEmpty ()) {
                    inventory.clearContent();
                    inventory.dropAll();
                    inventory.armor.clear();
                    inventory.player.setItemSlot(EquipmentSlot.CHEST, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.FEET, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.HEAD, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.LEGS, ItemStack.EMPTY);
                    inventory.setChanged();
                }
            }
            for (ItemStack itemStack : inventory.offhand) {
                if (!itemStack.isEmpty ()) {
                    inventory.clearContent();
                    inventory.dropAll();
                    inventory.offhand.clear();
                    inventory.player.setItemSlot(EquipmentSlot.OFFHAND, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.OFFHAND, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.OFFHAND, ItemStack.EMPTY);
                    inventory.player.setItemSlot(EquipmentSlot.OFFHAND, ItemStack.EMPTY);
                    inventory.setChanged();
                }
            }
            inventory.clearContent();
            inventory.setChanged();
        }
    }
}
